import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ulearning_app/common/values/colors.dart';

AppBar buildAppBar(){
  return AppBar(
    centerTitle: true,
    bottom: PreferredSize(
      preferredSize: Size.fromHeight(1.0),
      child: Container(
        color: AppColors.primarySecondaryBackground,
        height: 1.0,
      ),
    ),
    title: Text(
      'log in',
      style: TextStyle(
        color: AppColors.primaryText,
        fontSize: 16.sp,
        fontWeight: FontWeight.normal,
      ),
    ),
  );
}


Widget buildThirdPartyLogin(BuildContext context){
  return Container(
    margin: EdgeInsets.only(
      top: 40.h,
      bottom: 20.h,
    ),
    padding: EdgeInsets.only(left: 20.w,right: 20.w),
    child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      children: [
        _reusableIcons('google'),
        _reusableIcons('apple'),
        _reusableIcons('facebook'),
      ],
    ),
  );
}

Widget _reusableIcons(String iconName){
  return GestureDetector(
    onTap: (){

    },
    child: SizedBox(
      width: 40.w,
      height: 40.w,
      child: Image.asset(
          "assets/icons/${iconName}.png"
      ),
    ),
  );
}

Widget reusableText(String text){
  return Container(
    margin: EdgeInsets.only(bottom: 5.h,),
    child: Text(
      text,
      style: TextStyle(
        color: Colors.grey.withOpacity(0.9),
        fontWeight: FontWeight.normal,
        fontSize: 14.sp,
      ),
    ),
  );
}

Widget buildTextField(String hintText,String textType,String iconName){
  return Container(
    width: 280.w,
    height: 50.h,
    margin: EdgeInsets.only(bottom: 10.h),
    decoration: BoxDecoration(
      color: Colors.white,
      borderRadius: BorderRadius.all(Radius.circular(10.w)),
      border: Border.all(color: AppColors.primaryFourElementText),
    ),
    child: Row(
      children: [
        Container(
          width: 16.w,
          height: 16.w,
          margin: EdgeInsets.only(left: 17.w,),
          child: Image.asset("assets/icons/${iconName}.png"),
        ),
        Container(
          width: 200.w,
          height: 50.h,
          margin: EdgeInsets.only(left: 17.w,),
          child: TextField(
            keyboardType: TextInputType.multiline,
            decoration: InputDecoration(
              hintText: hintText,
              hintStyle: TextStyle(
                color: AppColors.primarySecondaryElementText,
                height: 1.h,
              ),
              border: const OutlineInputBorder(
                borderSide: BorderSide(
                  color: Colors.transparent,
                ),
              ),
              enabledBorder: const OutlineInputBorder(
                borderSide: const BorderSide(
                  color: Colors.transparent,
                ),
              ),
              disabledBorder: const OutlineInputBorder(
                borderSide: const BorderSide(
                  color: Colors.transparent,
                ),
              ),
              focusedBorder:const  OutlineInputBorder(
                borderSide: BorderSide(
                  color: Colors.transparent,
                ),
              ),
            ),
            style: TextStyle(
              color: AppColors.primaryText,
              fontFamily: "Avenir",
              fontSize:12.sp,
              fontWeight: FontWeight.normal,

            ),
            autofocus: false,
            obscureText: textType == 'password' ? true:false,
          ),
        ),
      ],
    ),
  );
}

Widget forgetPassword(){
  return Container(
    margin: EdgeInsets.only(left: 25.w),
    width: 250.w,
    height: 40.h,
    child: GestureDetector(
      onTap: (){

      },
      child: Text(
        'forget password',
         style: TextStyle(
           color: Colors.black,
           decoration: TextDecoration.underline,
           fontSize: 12.sp,
           decorationColor: AppColors.primaryText,
         ),
      ),
    ),
  );
}

Widget buildLoginAndRegButton(String buttonName,String buttonType){
  return GestureDetector(
    onTap: (){

    },
    child: Container(
      width: 325.w,
      height: 50.h,
      margin: EdgeInsets.only(left: 25.w,right: 25.w,top: buttonType == 'login' ? 30.h : 10.h),
      decoration: BoxDecoration(
        color: buttonType == 'login' ? AppColors.primaryElement:AppColors.primaryBackground,
        borderRadius: BorderRadius.circular(15.w),
        border: Border.all(
          color: buttonType == 'login' ? Colors.transparent:AppColors.primaryElement,
        ),
        boxShadow: [
          BoxShadow(
            spreadRadius: 1,
            blurRadius: 2,
            offset: Offset(0,1),
            color: Colors.grey.withOpacity(0.1),
          ),
        ],
      ),
      child: Center(
        child: Text(
          buttonName,
          style: TextStyle(
            fontSize: 16.sp,
            fontWeight: FontWeight.normal,
            color: buttonType == 'login' ? AppColors.primaryBackground : AppColors.primaryText,
          ),
        ),
      ),
    ),
  );
}